<template>
  <svg aria-hidden="true" class="svg-icon" :class="className" :style="style">
    <use :xlink:href="`#icon-${name}`" />
  </svg>
</template>

<script setup>
  import { computed } from 'vue';
  const props = defineProps({
    name: {
      type: String,
      required: true,
    },
    className: {
      type: String,
      default: '',
    },
    size: {
      type: [Number, String],
      default: 16,
    },
  });

  const style = computed(() => {
    if (typeof props.size === 'number') {
      return {
        width: `${props.size}px`,
        height: `${props.size}px`,
      };
    } else {
      return {
        width: props.size,
        height: props.size,
      };
    }
  });
</script>

<style scoped>
  .svg-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
  }
</style>
